import java.util.Arrays;
import java.util.PriorityQueue;

public class Test {
    public static void main(String[] args) {
        TestHeap testHeap=new TestHeap();
        int[] array={27,15,19,18,28,34,65,49,25,37};
        testHeap.initElem(array);
        testHeap.createHeap();
        System.out.println(testHeap);

        testHeap.offer(80);
        System.out.println(testHeap);

        testHeap.poll();
        System.out.println(testHeap);

        testHeap.heapSort();
        System.out.println(testHeap);
    }


    //认识一下 PriorityQueue
    public static void main1(String[] args) {
        //PriorityQueue默认为小根堆
        PriorityQueue<Integer> priorityQueue=new PriorityQueue<>();

        //注意插入的元素一定是要可比较的，因为其内部源代码就是通过可比较元素来实现的
        //除非你重写其比较器的代码
        priorityQueue.offer(12);
        priorityQueue.offer(40);
        priorityQueue.offer(7);
        priorityQueue.offer(81);
        priorityQueue.offer(8);
        priorityQueue.offer(45);
        priorityQueue.offer(98);

        System.out.println(priorityQueue);
        System.out.println(priorityQueue.size());
        System.out.println(priorityQueue.peek());

        priorityQueue.poll();
        System.out.println(priorityQueue);
        System.out.println(priorityQueue.size());
        System.out.println(priorityQueue.peek());

        if(priorityQueue.isEmpty()){
            System.out.println("优先级队列为空");
        }else{
            System.out.println("优先级队列不为空");
        }

        priorityQueue.clear();
        if(priorityQueue.isEmpty()){
            System.out.println("优先级队列为空");
        }else{
            System.out.println("优先级队列不为空");
        }
    }
}
